package com.z.controller;

import com.z.service.UsersService;
import com.z.service.impl.UsersServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet ("/updatebyuid")
public class UpdateByUidServlet extends HttpServlet {
    private UsersService usersService=new UsersServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String uid = req.getParameter("uid");
        String level = req.getParameter("level");
        Integer update =-1;
        update =usersService.updatebyuid(Integer.valueOf(uid),Integer.parseInt(level));
        if(update>0)
        {
            req.setAttribute("msg","停用成功");
            req.getRequestDispatcher("/manageUser").forward(req,resp);
        }else
        {
            req.setAttribute("msg","停用失败");
            req.getRequestDispatcher("/manageUser").forward(req,resp);
        }
    }
}
